// /member/cart

import type { CartItem } from '@/types/cart'
import { http } from '@/utils/https'

// 加入购物车接口
export const postMemberCart = (data: { skuId: string; count: number }) => {
  return http({
    url: '/member/cart',
    method: 'POST',
    data,
  })
}

// 获取购物车列表
export const getMemberCartList = () => {
  return http<CartItem[]>({
    url: '/member/cart',
    method: 'GET',
  })
}

/**
 * 删除购物车单品
 * @param data 请求提参数 ids skuId的集合
 */
export const deleteMemberCart = (data: { ids: string[] }) => {
  return http({
    url: '/member/cart',
    method: 'DELETE',
    data,
  })
}

/**
 * 修改购物车单品
 * @prama skuId  selected 选中状态 count 商品数量
 */
export const editMemberCartItem = (skuId: string, data: { count?: number; selected?: boolean }) => {
  return http({
    url: `/member/cart/${skuId}`,
    method: 'PUT',
    data,
  })
}

/**
 *商品是否全选
 *
 *@prama selected 是否全选
 */

export const getMemberCartAllSelect = (data: { selected: boolean }) => {
  return http({
    url: '/member/cart/selected',
    method: 'PUT',
    data,
  })
}
